import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class PaymentItemCheckbox extends StatelessWidget with CheckBoxMixin {
  final bool isSelect;
  final bool isEnable;

  final String title;
  final String date;
  final String unit;
  final num amount;
  final bool isSelectMode;
  final String type;

  const PaymentItemCheckbox(
      {Key key,
      this.type,
      this.isSelect,
      this.isEnable = true,
      this.title,
      this.isSelectMode,
      this.date,
      this.unit,
      this.amount})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
        left: getDp(29),
        right: getDp(19),
        top: getDp(23),
        bottom: getDp(23),
      ),
      decoration: BoxDecoration(
          color: isSelect == true ? aceSelectBackgroundColor : Colors.white,
          border: Border(
              bottom: BorderSide(
            color: aceWhiteGreyColor,
            width: getDp(0.5),
          ))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          IndexedStack(
            children: [
              buildSelectWidget,
              Column(
                children: [
                  SvgPicture.asset(
                    type == 'in'
                        ? A.assetsImagesDashboardAddCashIn
                        : A.assetsImagesDashboardAddCashOut,
                    width: getDp(15),
                    height: getDp(15),
                  ),
                  SizedBox(
                    height: getDp(14),
                  ),
                  Text(
                    type == 'in' ? 'Money-In' : 'Money-Out',
                    style: TextStyle(
                      color: aceDarkGrayColor,
                      fontSize: getSp(12),
                      fontWeight: FontWeight.w400,
                      height: 14 / 12,
                    ),
                  )
                ],
              )
            ],
            index: isSelectMode ? 0 : 1,
          ),
          SizedBox(
            width: getDp(24),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 1,
                  ),
                ),
                AppSpaces.h6,
                Text(
                  '${S.current.date}: $date',
                  style: TextStyle(
                    color: aceDarkGrayColor,
                    fontSize: getSp(14),
                    fontWeight: FontWeight.w400,
                    height: 1,
                  ),
                ),
              ],
            ),
          ),
          Text.rich(TextSpan(children: [
            TextSpan(
              text: type == 'in' ? '+ ' : '- ',
              style: TextStyle(
                fontSize: getSp(16),
                color: CashUtils.getColor(type == 'in' ? 1 : -1),
                fontWeight: FontWeight.bold,
                height: 14 / 12,
              ),
            ),
            TextSpan(
              text: '$unit ${CashUtils.ignoreFormatCashAmount(amount)}',
              style: TextStyle(
                color: aceBlackColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w700,
                height: 14 / 16,
              ),
            ),
          ], style: TextStyle(fontFamily: "DinRoundPro"))),
        ],
      ),
    );
  }
}
